<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Category_m extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    function edit($CategoryTracker) {
        
    }

    function delete($CategoryTracker) {
        
    }

    function detail($CategoryTracker) {
        
    }

    function all() {
        $query = $this->db->query('SELECT * FROM category');
        return $query->result();
    }

    function search($keyToSearch) {
        
    }

    function create($CategoryInput) {

        $ID = time() + rand(1000000, 9999999);
        $Tracker = md5($ID);
        $Name = $CategoryInput['CategoryName'];
        $Info = $CategoryInput['CategoryInfo'];
        $CreatedBy = 123456789;
        $ModifiedBy = 123456789;
        $Image = $CategoryInput['CategoryImage'];
        $Created = $Modified = time();

        $data = array(
            'CategoryID' => $ID,
            'CategoryTracker' => $Tracker,
            'CategoryName' => $Name,
            'CategoryInfo' => $Info,
            'CategoryCreatedBy' => $CreatedBy,
            'CategoryModifiedBy' => $ModifiedBy,
            'CategoryImage' => $Image,
            'CategoryCreatedDate' => $Created,
            'CategoryModifiedDate' => $Modified
        );

        $result = $this->db->insert('category', $data);
        return $result;
    }

}
